package flc.ast.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.TailorBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class TailorAdapter extends StkProviderMultiAdapter<TailorBean> {

    public TailorAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(85));
        addItemProvider(new TailorProvider());
    }

    private class TailorProvider extends BaseItemProvider<TailorBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_tailor;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, TailorBean bean) {
            baseViewHolder.setImageResource(R.id.ivTailorItemImg, bean.getImg());
            baseViewHolder.setText(R.id.tvTailorItemName, bean.getName());
            if (bean.isSelect()) {
                baseViewHolder.getView(R.id.llTailorItem).setBackgroundResource(R.drawable.xuankuang1);
                baseViewHolder.getView(R.id.ivTailorItemImg).setBackground(null);
                baseViewHolder.setTextColor(R.id.tvTailorItemName, Color.parseColor("#FFFFFF"));
            } else {
                baseViewHolder.getView(R.id.llTailorItem).setBackground(null);
                baseViewHolder.getView(R.id.ivTailorItemImg).setBackgroundResource(R.drawable.shape_tailor);
                baseViewHolder.setTextColor(R.id.tvTailorItemName, Color.parseColor("#4DFFFFFF"));
            }
        }
    }
}
